import { to } from "await-to-js";
import { getProfile } from "../db/user";

export default defineEventHandler(async event => {
    const [error, data] = await to(getProfile(event.context.auth._id));

    if (error) throw createError({ statusCode: 404, statusMessage: error.message });
    else return { code: 0, msg: 'Success!', data };
});
